package com.repository;

import com.entity.UserAndRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;


/**
 * @author Yadasu
 * @date 2020/12/22 13:45
 */
public interface UserAndRoleRepository  extends JpaRepository<UserAndRole,Integer> {

    @Query(value = "select * from sys_user_role  where  uid=:uid ",nativeQuery = true)
    UserAndRole findByUid(@Param("uid")Integer uid);


    @Modifying
    @Transactional
    @Query(value = "delete  from sys_user_role where uid=?1",nativeQuery = true)
    Integer delUserInRole(Integer id);

}
